package com.xzz;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 黄会准
 * @since 2020-11-17
 */
public class KidsWithCandies {
    public static void main(String[] args) {
        int[] candies1 = {2, 3, 5, 1, 3};
        int[] candies2 = {4, 2, 1, 1, 2};
        int[] candies3 = {12, 1, 12};
        System.out.println(kidsWithCandies(candies1, 3));
        System.out.println(kidsWithCandies(candies2, 1));
        System.out.println(kidsWithCandies(candies3, 10));

    }

    public static List<Boolean> kidsWithCandies(int[] candies, int extraCandies) {
        List<Boolean> list = new ArrayList<>();
//        for (int i = 0; i < candies.length; i++) {
//            int temp = 0;
//            for (int j = 0; j < candies.length; j++) {
//                if (candies[i]+extraCandies >= candies[j]) {
//                    temp++;
//                }
//            }
//            if(temp==candies.length){
//                list.add(true);
//            }else {
//                list.add(false);
//            }
//        }

        int max = candies[0];
        for (int i = 1; i < candies.length; i++) {
            if (candies[i] > max) {
                max = candies[i];
            }
        }
        for (int i = 0; i < candies.length; i++) {
            if(candies[i]+extraCandies>=max){
                list.add(true);
            }else {
                list.add(false);
            }
        }
        return list;
    }
}
